<template>
	<m-layout class="order" title="" gap="0 24" :go-back="false">
		<view slot="back">
			<m-image2 :size="[364, 32]" src="../../static/images/pages/index/header-left.png" radius="8" />
		</view>
		<!-- 公告 -->
		<m-notice ref="notice" class="mt-20" />
		<!-- <fun class="mt-20" /> -->
		<m-block class="myReward mt-20" bg-color="#fff">
			<view class="_topBox flex-column ptb-32 plr-36">
				<text class="fs25" style="color: #482000">我的收益</text>
				<view class="flex">
					<text class="fs48 fw-600" style="color: #482000">{{ (tototalR || 0) | integer(2) }}</text>
				</view>
			</view>
			<fun />
		</m-block>
		<!--  -->
		<m-block class="wxxcx mt-20" @click="jumpToWeapp">
			<image src="../../static/images/pages/index/wxxcx.png" mode=""></image>
		</m-block>
		<!-- 		<m-block class=" flex-column mt-20 ptb-16 plr-32">
			<view class="flex-between ptb-16" @click="jumpToWeapp">
				<view class="flex">
					<m-icon size="42" type="wxxcx" />
					<text class="fw-600 fs24 ml-12">小程序</text>
				</view>
				<view class="flex">
					<text class="fs22 goTo">前往</text>
					<m-icon size="24" color="#888" type="icon-qianjin" />
				</view>
			</view>
			<view class="flex-between ptb-16" @click="jumpToWeapp2" style="border-top: 1px solid #EEEEEE">
				<view class="flex">
					<m-icon size="45" type="wxgzh" />
					<text class="fw-600 fs24 ml-12">公众号</text>
				</view>
				<view class="flex">
					<text class="fs22 goTo">前往</text>
					<m-icon size="24" color="#888" type="icon-qianjin" />
				</view>
			</view>
		</m-block> -->
		<m-block class="linkList" bg-color="unset">
			<view class="share mt-20" @click="Jump('/pages/home/share/share')"></view>
			<view class="classfy mt-20" @click="Jump('/pages/classfy/classfy')"></view>
		</m-block>
		<!-- 广告位 -->

		<m-block class="adsList flex-column" bg-color="unset" radius="0">
			<image @click="JumpUrl(item.content_abstract, 2)" class="mt-20" v-for="item in bnannerList" :src="item.picurl" mode=""></image>
		</m-block>
	</m-layout>
</template>

<script>
import { mytotal, mytotalW3 } from '@/api/Users.js';
import fun from './components/fun.vue';
import { GetNewsPage } from '@/api/News.js';
export default {
	components: { fun },
	data() {
		return {
			myTotal: {}, //  我的个人业绩
			bnannerList: [],
			myTotalW3: {},
			tototalR: 0
		};
	},
	onLoad() {
		// banklist()
		this.$nextTick(() => {
			this.$refs.notice.getNotice();
			this.getBanner();
		});
	},
	onShow() {
		this.getMyTotal();
	},
	methods: {
		async getMyTotal() {
			const { success, msg, data } = await mytotal();
			this.myTotal = data;
			await this.sleep(300);
			const res = await mytotalW3();
			this.myTotalW3 = res.data;
			const a = Number(this.myTotal.c_5) + Number(this.myTotal.c_16) + Number(this.myTotal.c_11) + Number(this.myTotal.c_12);
			const b =
				Number(this.myTotalW3.c_5) +
				Number(this.myTotalW3.c_16) +
				Number(this.myTotalW3.c_11) +
				Number(this.myTotalW3.c_12) +
				Number(this.myTotalW3.c_21) +
				Number(this.myTotalW3.c_22);
			this.tototalR = a + b;
		},
		// 获取banner列表
		async getBanner() {
			const { success, list, msg, code } = await GetNewsPage({
				code: 'guanggao',
				pageIndex: 1,
				pageSize: 10
			});
			this.bnannerList = list;
		},
		ToMiniProgram() {
			uni.navigateToMiniProgram({
				appId: 'wx6fae6e859496abb2 ', // 目标小程序的appId
				// path: 'pages/work/index', // 打开的页面路径，如果留空则打开首页
				extraData: {}, // 需要传递给目标小程序的数据
				envVersion: 'release', // 打开的小程序版本
				success(res) {
					// 打开成功
				}
			});
		},
		jumpToWeapp() {
			if (typeof wx !== 'undefined' && wx.miniProgram) {
				wx.navigateToMiniProgram({
					appId: 'wxd252c250b83a3b24',
					path: 'pages/wxopen/wxopen',
					extraData: {
						// 'data1': 'test'
					},
					success(res) {
						// 打开成功
					}
				});
			} else {
				let weappUrl = `weixin://dl/business/?appid=wxd252c250b83a3b24&path=pages/wxopen/wxopen`;
				this.openURL({ openUrl: weappUrl, openType: 'unwebview' });
			}
		},
		jumpToWeapp2() {
			let weappUrl = `https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg3Nzc2ODk4Mg==&scene=110#wechat_redirect`;
			// window.location.href = weappUrl;
			//跳转，不保留历史消息
			// window.location.replace(weappUrl);
			this.openURL({ openUrl: weappUrl, openType: 'unwebview' });
		}
	}
};
</script>

<style lang="scss">
.linkList {
	.share {
		border-radius: 12rpx;
		overflow: hidden;
		height: 191rpx;
		background: url('../../static/images/pages/index/share.png');
		background-size: 100% 191rpx;
	}

	.classfy {
		border-radius: 12rpx;
		overflow: hidden;
		height: 191rpx;
		background: url('../../static/images/pages/index/classfy.png');
		background-size: 100% 191rpx;
	}
}

.myReward {
	._topBox {
		box-sizing: border-box;
		height: 144rpx;
		background: url('../../static/images/pages/index/topbg.png');
		background-size: 100% 144rpx;
	}
}

.adsList {
	padding-bottom: 120rpx !important;
	image {
		border-radius: 10rpx;
		width: 100%;
		height: 142rpx;
	}
}

.goTo {
	// padding: 4rpx 12rpx;
	// border: 2rpx solid #909090;
	// border-radius: 12rpx;
}
.wxxcx {
	height: 200rpx;
	& > image {
		height: 100%;
		width: 100%;
	}
}
</style>
